<?php
/**
 *  +----------------------------------------------------------------------
 *  | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
 *  +----------------------------------------------------------------------
 *  | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
 *  +----------------------------------------------------------------------
 *  | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
 *  +----------------------------------------------------------------------
 *  | Author: CRMEB Team <admin@crmeb.com>
 *  +----------------------------------------------------------------------
 */

/**
 * votes
 * @author crud自动生成代码
 * @date 2025/08/24 10:41:01
 */

namespace app\dao\crud;


use app\dao\BaseDao;
use app\model\crud\Votes;

/**
 * Class VotesDao
 * @date 2025/08/24
 * @package app\dao\crud
 */
class VotesDao extends BaseDao
{

    /**
     * 设置模型
     * @return string
     * @date 2025/08/24
     */
    protected function setModel(): string
    {
        return Votes::class;
    }
    /**
     * 搜索
     * @param array $where
     * @return \crmeb\basic\BaseModel
     * @throws \ReflectionException
     * @date {%DATE%}
     */
    public function searchCrudModel(array $where = [], $field = ['*'], string $order = '', array $with = [])
    {
        return $this->getModel()->field($field)->when($order !== '', function ($query) use ($order) {
            $query->order($order);
        })->when($with, function ($query) use ($with) {
            $query->with($with);
        })->when($where['posts_id'], function ($query) use ($with,$where) {
            $query->where('posts_id','=',$where['posts_id']);
        });
    }

}
